﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Playables.PlayableHandle
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using System.Runtime.CompilerServices;
using UnityEngine.Bindings;
using UnityEngine.Scripting;

#nullable disable
namespace UnityEngine.Playables
{
  [UsedByNativeCode]
  [NativeHeader("Runtime/Director/Core/HPlayableGraph.h")]
  [NativeHeader("Runtime/Director/Core/HPlayable.h")]
  [NativeHeader("Runtime/Export/Director/PlayableHandle.bindings.h")]
  public struct PlayableHandle : IEquatable<PlayableHandle>
  {
    internal IntPtr m_Handle;
    internal uint m_Version;
    private static readonly PlayableHandle m_Null = new PlayableHandle();

    internal T GetObject<T>() where T : class, IPlayableBehaviour
    {
      if (!this.IsValid())
        return default (T);
      object scriptInstance = this.GetScriptInstance();
      return scriptInstance == null ? default (T) : (T) scriptInstance;
    }

    [VisibleToOtherModules]
    internal bool IsPlayableOfType<T>() => this.GetPlayableType() == typeof (T);

    public static PlayableHandle Null => PlayableHandle.m_Null;

    internal Playable GetInput(int inputPort) => new Playable(this.GetInputHandle(inputPort));

    internal Playable GetOutput(int outputPort) => new Playable(this.GetOutputHandle(outputPort));

    internal bool SetInputWeight(int inputIndex, float weight)
    {
      if (!this.CheckInputBounds(inputIndex))
        return false;
      this.SetInputWeightFromIndex(inputIndex, weight);
      return true;
    }

    internal float GetInputWeight(int inputIndex)
    {
      return this.CheckInputBounds(inputIndex) ? this.GetInputWeightFromIndex(inputIndex) : 0.0f;
    }

    internal void Destroy() => this.GetGraph().DestroyPlayable<Playable>(new Playable(this));

    public static bool operator ==(PlayableHandle x, PlayableHandle y)
    {
      return PlayableHandle.CompareVersion(x, y);
    }

    public static bool operator !=(PlayableHandle x, PlayableHandle y)
    {
      return !PlayableHandle.CompareVersion(x, y);
    }

    public override bool Equals(object p) => p is PlayableHandle other && this.Equals(other);

    public bool Equals(PlayableHandle other) => PlayableHandle.CompareVersion(this, other);

    public override int GetHashCode() => this.m_Handle.GetHashCode() ^ this.m_Version.GetHashCode();

    internal static bool CompareVersion(PlayableHandle lhs, PlayableHandle rhs)
    {
      return lhs.m_Handle == rhs.m_Handle && (int) lhs.m_Version == (int) rhs.m_Version;
    }

    internal bool CheckInputBounds(int inputIndex) => this.CheckInputBounds(inputIndex, false);

    internal bool CheckInputBounds(int inputIndex, bool acceptAny)
    {
      if (inputIndex == -1 & acceptAny)
        return true;
      if (inputIndex < 0)
        throw new IndexOutOfRangeException("Index must be greater than 0");
      if (this.GetInputCount() <= inputIndex)
        throw new IndexOutOfRangeException("inputIndex " + inputIndex.ToString() + " is greater than the number of available inputs (" + this.GetInputCount().ToString() + ").");
      return true;
    }

    [VisibleToOtherModules]
    internal bool IsNull() => PlayableHandle.IsNull_Injected(ref this);

    [VisibleToOtherModules]
    internal bool IsValid() => PlayableHandle.IsValid_Injected(ref this);

    [FreeFunction("PlayableHandleBindings::GetPlayableType", HasExplicitThis = true, ThrowsException = true)]
    [VisibleToOtherModules]
    internal System.Type GetPlayableType() => PlayableHandle.GetPlayableType_Injected(ref this);

    [FreeFunction("PlayableHandleBindings::GetJobType", HasExplicitThis = true, ThrowsException = true)]
    [VisibleToOtherModules]
    internal System.Type GetJobType() => PlayableHandle.GetJobType_Injected(ref this);

    [FreeFunction("PlayableHandleBindings::SetScriptInstance", HasExplicitThis = true, ThrowsException = true)]
    [VisibleToOtherModules]
    internal void SetScriptInstance(object scriptInstance)
    {
      PlayableHandle.SetScriptInstance_Injected(ref this, scriptInstance);
    }

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::CanChangeInputs", HasExplicitThis = true, ThrowsException = true)]
    internal bool CanChangeInputs() => PlayableHandle.CanChangeInputs_Injected(ref this);

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::CanSetWeights", HasExplicitThis = true, ThrowsException = true)]
    internal bool CanSetWeights() => PlayableHandle.CanSetWeights_Injected(ref this);

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::CanDestroy", HasExplicitThis = true, ThrowsException = true)]
    internal bool CanDestroy() => PlayableHandle.CanDestroy_Injected(ref this);

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::GetPlayState", HasExplicitThis = true, ThrowsException = true)]
    internal PlayState GetPlayState() => PlayableHandle.GetPlayState_Injected(ref this);

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::Play", HasExplicitThis = true, ThrowsException = true)]
    internal void Play() => PlayableHandle.Play_Injected(ref this);

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::Pause", HasExplicitThis = true, ThrowsException = true)]
    internal void Pause() => PlayableHandle.Pause_Injected(ref this);

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::GetSpeed", HasExplicitThis = true, ThrowsException = true)]
    internal double GetSpeed() => PlayableHandle.GetSpeed_Injected(ref this);

    [FreeFunction("PlayableHandleBindings::SetSpeed", HasExplicitThis = true, ThrowsException = true)]
    [VisibleToOtherModules]
    internal void SetSpeed(double value) => PlayableHandle.SetSpeed_Injected(ref this, value);

    [FreeFunction("PlayableHandleBindings::GetTime", HasExplicitThis = true, ThrowsException = true)]
    [VisibleToOtherModules]
    internal double GetTime() => PlayableHandle.GetTime_Injected(ref this);

    [FreeFunction("PlayableHandleBindings::SetTime", HasExplicitThis = true, ThrowsException = true)]
    [VisibleToOtherModules]
    internal void SetTime(double value) => PlayableHandle.SetTime_Injected(ref this, value);

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::IsDone", HasExplicitThis = true, ThrowsException = true)]
    internal bool IsDone() => PlayableHandle.IsDone_Injected(ref this);

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::SetDone", HasExplicitThis = true, ThrowsException = true)]
    internal void SetDone(bool value) => PlayableHandle.SetDone_Injected(ref this, value);

    [FreeFunction("PlayableHandleBindings::GetDuration", HasExplicitThis = true, ThrowsException = true)]
    [VisibleToOtherModules]
    internal double GetDuration() => PlayableHandle.GetDuration_Injected(ref this);

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::SetDuration", HasExplicitThis = true, ThrowsException = true)]
    internal void SetDuration(double value) => PlayableHandle.SetDuration_Injected(ref this, value);

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::GetPropagateSetTime", HasExplicitThis = true, ThrowsException = true)]
    internal bool GetPropagateSetTime() => PlayableHandle.GetPropagateSetTime_Injected(ref this);

    [FreeFunction("PlayableHandleBindings::SetPropagateSetTime", HasExplicitThis = true, ThrowsException = true)]
    [VisibleToOtherModules]
    internal void SetPropagateSetTime(bool value)
    {
      PlayableHandle.SetPropagateSetTime_Injected(ref this, value);
    }

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::GetGraph", HasExplicitThis = true, ThrowsException = true)]
    internal PlayableGraph GetGraph()
    {
      PlayableGraph ret;
      PlayableHandle.GetGraph_Injected(ref this, out ret);
      return ret;
    }

    [FreeFunction("PlayableHandleBindings::GetInputCount", HasExplicitThis = true, ThrowsException = true)]
    [VisibleToOtherModules]
    internal int GetInputCount() => PlayableHandle.GetInputCount_Injected(ref this);

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::SetInputCount", HasExplicitThis = true, ThrowsException = true)]
    internal void SetInputCount(int value)
    {
      PlayableHandle.SetInputCount_Injected(ref this, value);
    }

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::GetOutputCount", HasExplicitThis = true, ThrowsException = true)]
    internal int GetOutputCount() => PlayableHandle.GetOutputCount_Injected(ref this);

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::SetOutputCount", HasExplicitThis = true, ThrowsException = true)]
    internal void SetOutputCount(int value)
    {
      PlayableHandle.SetOutputCount_Injected(ref this, value);
    }

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::SetInputWeight", HasExplicitThis = true, ThrowsException = true)]
    internal void SetInputWeight(PlayableHandle input, float weight)
    {
      PlayableHandle.SetInputWeight_Injected(ref this, ref input, weight);
    }

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::SetDelay", HasExplicitThis = true, ThrowsException = true)]
    internal void SetDelay(double delay) => PlayableHandle.SetDelay_Injected(ref this, delay);

    [FreeFunction("PlayableHandleBindings::GetDelay", HasExplicitThis = true, ThrowsException = true)]
    [VisibleToOtherModules]
    internal double GetDelay() => PlayableHandle.GetDelay_Injected(ref this);

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::IsDelayed", HasExplicitThis = true, ThrowsException = true)]
    internal bool IsDelayed() => PlayableHandle.IsDelayed_Injected(ref this);

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::GetPreviousTime", HasExplicitThis = true, ThrowsException = true)]
    internal double GetPreviousTime() => PlayableHandle.GetPreviousTime_Injected(ref this);

    [FreeFunction("PlayableHandleBindings::SetLeadTime", HasExplicitThis = true, ThrowsException = true)]
    [VisibleToOtherModules]
    internal void SetLeadTime(float value) => PlayableHandle.SetLeadTime_Injected(ref this, value);

    [FreeFunction("PlayableHandleBindings::GetLeadTime", HasExplicitThis = true, ThrowsException = true)]
    [VisibleToOtherModules]
    internal float GetLeadTime() => PlayableHandle.GetLeadTime_Injected(ref this);

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::GetTraversalMode", HasExplicitThis = true, ThrowsException = true)]
    internal PlayableTraversalMode GetTraversalMode()
    {
      return PlayableHandle.GetTraversalMode_Injected(ref this);
    }

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::SetTraversalMode", HasExplicitThis = true, ThrowsException = true)]
    internal void SetTraversalMode(PlayableTraversalMode mode)
    {
      PlayableHandle.SetTraversalMode_Injected(ref this, mode);
    }

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::GetJobData", HasExplicitThis = true, ThrowsException = true)]
    internal IntPtr GetJobData() => PlayableHandle.GetJobData_Injected(ref this);

    [FreeFunction("PlayableHandleBindings::GetTimeWrapMode", HasExplicitThis = true, ThrowsException = true)]
    [VisibleToOtherModules]
    internal DirectorWrapMode GetTimeWrapMode()
    {
      return PlayableHandle.GetTimeWrapMode_Injected(ref this);
    }

    [VisibleToOtherModules]
    [FreeFunction("PlayableHandleBindings::SetTimeWrapMode", HasExplicitThis = true, ThrowsException = true)]
    internal void SetTimeWrapMode(DirectorWrapMode mode)
    {
      PlayableHandle.SetTimeWrapMode_Injected(ref this, mode);
    }

    [FreeFunction("PlayableHandleBindings::GetScriptInstance", HasExplicitThis = true, ThrowsException = true)]
    private object GetScriptInstance() => PlayableHandle.GetScriptInstance_Injected(ref this);

    [FreeFunction("PlayableHandleBindings::GetInputHandle", HasExplicitThis = true, ThrowsException = true)]
    private PlayableHandle GetInputHandle(int index)
    {
      PlayableHandle ret;
      PlayableHandle.GetInputHandle_Injected(ref this, index, out ret);
      return ret;
    }

    [FreeFunction("PlayableHandleBindings::GetOutputHandle", HasExplicitThis = true, ThrowsException = true)]
    private PlayableHandle GetOutputHandle(int index)
    {
      PlayableHandle ret;
      PlayableHandle.GetOutputHandle_Injected(ref this, index, out ret);
      return ret;
    }

    [FreeFunction("PlayableHandleBindings::SetInputWeightFromIndex", HasExplicitThis = true, ThrowsException = true)]
    private void SetInputWeightFromIndex(int index, float weight)
    {
      PlayableHandle.SetInputWeightFromIndex_Injected(ref this, index, weight);
    }

    [FreeFunction("PlayableHandleBindings::GetInputWeightFromIndex", HasExplicitThis = true, ThrowsException = true)]
    private float GetInputWeightFromIndex(int index)
    {
      return PlayableHandle.GetInputWeightFromIndex_Injected(ref this, index);
    }

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool IsNull_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool IsValid_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern System.Type GetPlayableType_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern System.Type GetJobType_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void SetScriptInstance_Injected(
      ref PlayableHandle _unity_self,
      object scriptInstance);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool CanChangeInputs_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool CanSetWeights_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool CanDestroy_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern PlayState GetPlayState_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void Play_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void Pause_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern double GetSpeed_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void SetSpeed_Injected(ref PlayableHandle _unity_self, double value);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern double GetTime_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void SetTime_Injected(ref PlayableHandle _unity_self, double value);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool IsDone_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void SetDone_Injected(ref PlayableHandle _unity_self, bool value);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern double GetDuration_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void SetDuration_Injected(ref PlayableHandle _unity_self, double value);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool GetPropagateSetTime_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void SetPropagateSetTime_Injected(
      ref PlayableHandle _unity_self,
      bool value);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void GetGraph_Injected(
      ref PlayableHandle _unity_self,
      out PlayableGraph ret);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern int GetInputCount_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void SetInputCount_Injected(ref PlayableHandle _unity_self, int value);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern int GetOutputCount_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void SetOutputCount_Injected(ref PlayableHandle _unity_self, int value);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void SetInputWeight_Injected(
      ref PlayableHandle _unity_self,
      ref PlayableHandle input,
      float weight);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void SetDelay_Injected(ref PlayableHandle _unity_self, double delay);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern double GetDelay_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool IsDelayed_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern double GetPreviousTime_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void SetLeadTime_Injected(ref PlayableHandle _unity_self, float value);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern float GetLeadTime_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern PlayableTraversalMode GetTraversalMode_Injected(
      ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void SetTraversalMode_Injected(
      ref PlayableHandle _unity_self,
      PlayableTraversalMode mode);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern IntPtr GetJobData_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern DirectorWrapMode GetTimeWrapMode_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void SetTimeWrapMode_Injected(
      ref PlayableHandle _unity_self,
      DirectorWrapMode mode);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern object GetScriptInstance_Injected(ref PlayableHandle _unity_self);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void GetInputHandle_Injected(
      ref PlayableHandle _unity_self,
      int index,
      out PlayableHandle ret);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void GetOutputHandle_Injected(
      ref PlayableHandle _unity_self,
      int index,
      out PlayableHandle ret);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void SetInputWeightFromIndex_Injected(
      ref PlayableHandle _unity_self,
      int index,
      float weight);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern float GetInputWeightFromIndex_Injected(
      ref PlayableHandle _unity_self,
      int index);
  }
}
